package com.ty.day2;

import java.util.Arrays;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create 2023/11/7 19:18
 */
public class Task2 {
    public static void main(String[] args) {
        int[] a={0,1,2,3,4,5,6,7,8,9};
        int[] b=new int[a.length];
        Arrays.fill(b,1);
        int t;
        for (int i = 0; i < a.length/2; i++) {
            //随机生成0~9的数作为下标，方便交换
            int x = (int) (Math.random()*a.length);
            int y = (int) (Math.random()*a.length);
            if (b[x]==1&&b[y]==1){
                t=a[i];
                a[i]=a[x];
                a[x]=t;
                b[x]=0;
                b[y]=0;
            }
        }
        System.out.println(Arrays.toString(a));
    }
}
